package com.mark.controller;

import java.io.IOException;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.List;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mark.domain.Song;
import com.mark.service.SongService;


public class SongOptionsServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        SongService ss = new SongService();
        List<Song> options = ss.getSongOptions(1);
        String ans = options.get(new Random().nextInt(4)).getName();
        request.setAttribute("ans", ans);
        request.setAttribute("options", options);
        request.getRequestDispatcher("test.jsp").forward(request, response);
    }

}
